﻿using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

// Token: 0x020003C8 RID: 968
public class SmartConsole : MonoBehaviour
{
	// Token: 0x06001A7D RID: 6781 RVA: 0x000A54D6 File Offset: 0x000A36D6
	private void Awake()
	{
		if (!base.gameObject.activeSelf)
		{
			return;
		}
		if (this.m_font == null)
		{
			Debug.LogError("SmartConsole requires a font to be set in the inspector");
		}
		SmartConsole.Initialise(this);
	}

	// Token: 0x06001A7E RID: 6782 RVA: 0x000A550C File Offset: 0x000A370C
	private void Update()
	{
		if (!base.gameObject.activeSelf)
		{
			return;
		}
		if (SmartConsole.s_first)
		{
			if (SmartConsole.s_fps == null || SmartConsole.s_textInput == null)
			{
				Debug.LogWarning("Some variables are null that really shouldn't be! Did you make code changes whilst paused? Be aware that such changes are not safe in general!");
				return;
			}
			SmartConsole.s_first = false;
		}
		SmartConsole.HandleInput();
		if (SmartConsole.s_showConsole)
		{
			SmartConsole.s_visiblityLerp += Time.deltaTime / 0.4f;
		}
		else
		{
			SmartConsole.s_visiblityLerp -= Time.deltaTime / 0.4f;
		}
		SmartConsole.s_visiblityLerp = Mathf.Clamp01(SmartConsole.s_visiblityLerp);
		base.transform.position = Vector3.Lerp(SmartConsole.k_hidePosition, (!SmartConsole.s_drawFullConsole) ? SmartConsole.k_position : SmartConsole.k_fullPosition, this.SmootherStep(SmartConsole.s_visiblityLerp));
		base.transform.localScale = SmartConsole.k_scale;
		if (SmartConsole.s_textInput != null && SmartConsole.s_textInput.GetComponent<GUIText>() != null)
		{
			SmartConsole.s_textInput.GetComponent<GUIText>().text = ">" + SmartConsole.s_currentInputLine + ((!SmartConsole.s_blink) ? string.Empty : "_");
		}
		SmartConsole.s_flippy++;
		SmartConsole.s_flippy &= 7;
		if (SmartConsole.s_flippy == 0)
		{
			SmartConsole.s_blink = !SmartConsole.s_blink;
		}
		if (SmartConsole.s_drawFPS)
		{
			SmartConsole.s_fps.GetComponent<GUIText>().text = string.Empty + 1f / Time.deltaTime + " fps ";
			SmartConsole.s_fps.transform.position = new Vector3(0.8f, 1f, 0f);
		}
		else
		{
			SmartConsole.s_fps.transform.position = new Vector3(1f, 10f, 0f);
		}
	}

	// Token: 0x06001A7F RID: 6783 RVA: 0x000A5715 File Offset: 0x000A3915
	public static void Clear()
	{
		SmartConsole.s_outputHistory.Clear();
		SmartConsole.SetStringsOnHistoryElements();
	}

	// Token: 0x06001A80 RID: 6784 RVA: 0x000A5726 File Offset: 0x000A3926
	public static void Print(string message)
	{
		SmartConsole.WriteLine(message);
	}

	// Token: 0x06001A81 RID: 6785 RVA: 0x000A572E File Offset: 0x000A392E
	public static void WriteLine(string message)
	{
		SmartConsole.s_outputHistory.Add(SmartConsole.DeNewLine(message));
		SmartConsole.s_currentCommandHistoryIndex = SmartConsole.s_outputHistory.Count - 1;
		SmartConsole.SetStringsOnHistoryElements();
	}

	// Token: 0x06001A82 RID: 6786 RVA: 0x000A5758 File Offset: 0x000A3958
	public static void ExecuteLine(string inputLine)
	{
		SmartConsole.WriteLine(">" + inputLine);
		string[] array = SmartConsole.CComParameterSplit(inputLine);
		if (array.Length > 0)
		{
			if (SmartConsole.s_masterDictionary.ContainsKey(array[0]))
			{
				SmartConsole.s_commandHistory.Add(inputLine);
				SmartConsole.s_masterDictionary[array[0]].m_callback(inputLine);
			}
			else
			{
				SmartConsole.WriteLine("Unrecognised command or variable name: " + array[0]);
			}
		}
	}

	// Token: 0x06001A83 RID: 6787 RVA: 0x000A57D1 File Offset: 0x000A39D1
	public static void RemoveCommandIfExists(string name)
	{
		SmartConsole.s_commandDictionary.Remove(name);
		SmartConsole.s_masterDictionary.Remove(name);
	}

	// Token: 0x06001A84 RID: 6788 RVA: 0x000A57EC File Offset: 0x000A39EC
	public static void RegisterCommand(string name, string exampleUsage, string helpDescription, SmartConsole.ConsoleCommandFunction callback)
	{
		SmartConsole.Command command = new SmartConsole.Command();
		command.m_name = name;
		command.m_paramsExample = exampleUsage;
		command.m_help = helpDescription;
		command.m_callback = callback;
		if (!SmartConsole.s_commandDictionary.ContainsKey(name))
		{
			SmartConsole.s_commandDictionary.Add(name, command);
		}
		if (!SmartConsole.s_masterDictionary.ContainsKey(name))
		{
			SmartConsole.s_masterDictionary.Add(name, command);
		}
	}

	// Token: 0x06001A85 RID: 6789 RVA: 0x000A5853 File Offset: 0x000A3A53
	public static void RegisterCommand(string name, string helpDescription, SmartConsole.ConsoleCommandFunction callback)
	{
		SmartConsole.RegisterCommand(name, string.Empty, helpDescription, callback);
	}

	// Token: 0x06001A86 RID: 6790 RVA: 0x000A5862 File Offset: 0x000A3A62
	public static void RegisterCommand(string name, SmartConsole.ConsoleCommandFunction callback)
	{
		SmartConsole.RegisterCommand(name, string.Empty, "(no description)", callback);
	}

	// Token: 0x06001A87 RID: 6791 RVA: 0x000A5878 File Offset: 0x000A3A78
	public static SmartConsole.Variable<T> CreateVariable<T>(string name, string description, T initialValue) where T : new()
	{
		if (SmartConsole.s_variableDictionary.ContainsKey(name))
		{
			Debug.LogError("Tried to add already existing console variable!");
			return null;
		}
		SmartConsole.Variable<T> variable = new SmartConsole.Variable<T>(name, description, initialValue);
		SmartConsole.s_variableDictionary.Add(name, variable);
		SmartConsole.s_masterDictionary.Add(name, variable);
		return variable;
	}

	// Token: 0x06001A88 RID: 6792 RVA: 0x000A58C3 File Offset: 0x000A3AC3
	public static SmartConsole.Variable<T> CreateVariable<T>(string name, string description) where T : new()
	{
		return SmartConsole.CreateVariable<T>(name, description, Activator.CreateInstance<T>());
	}

	// Token: 0x06001A89 RID: 6793 RVA: 0x000A58D1 File Offset: 0x000A3AD1
	public static SmartConsole.Variable<T> CreateVariable<T>(string name) where T : new()
	{
		return SmartConsole.CreateVariable<T>(name, string.Empty);
	}

	// Token: 0x06001A8A RID: 6794 RVA: 0x000A58DE File Offset: 0x000A3ADE
	public static void DestroyVariable<T>(SmartConsole.Variable<T> variable) where T : new()
	{
		SmartConsole.s_variableDictionary.Remove(variable.m_name);
		SmartConsole.s_masterDictionary.Remove(variable.m_name);
	}

	// Token: 0x06001A8B RID: 6795 RVA: 0x000A5904 File Offset: 0x000A3B04
	private static void Help(string parameters)
	{
		foreach (SmartConsole.Command command in SmartConsole.s_commandDictionary.Values)
		{
			string str = command.m_name;
			for (int i = command.m_name.Length; i < 25; i++)
			{
				str += " ";
			}
			if (command.m_paramsExample.Length > 0)
			{
				str = str + " example: " + command.m_paramsExample;
			}
			else
			{
				str += "          ";
			}
			for (int j = command.m_paramsExample.Length; j < 35; j++)
			{
				str += " ";
			}
			SmartConsole.WriteLine(str + command.m_help);
		}
	}

	// Token: 0x06001A8C RID: 6796 RVA: 0x000A5A00 File Offset: 0x000A3C00
	private static void Echo(string parameters)
	{
		string text = string.Empty;
		string[] array = SmartConsole.CComParameterSplit(parameters);
		for (int i = 1; i < array.Length; i++)
		{
			text = text + array[i] + " ";
		}
		if (text.EndsWith(" "))
		{
			text.Substring(0, text.Length - 1);
		}
		SmartConsole.WriteLine(text);
	}

	// Token: 0x06001A8D RID: 6797 RVA: 0x000A5A63 File Offset: 0x000A3C63
	private static void Clear(string parameters)
	{
		SmartConsole.Clear();
	}

	// Token: 0x06001A8E RID: 6798 RVA: 0x000A5A6A File Offset: 0x000A3C6A
	private static void LastExceptionCallStack(string parameters)
	{
		SmartConsole.DumpCallStack(SmartConsole.s_lastExceptionCallStack);
	}

	// Token: 0x06001A8F RID: 6799 RVA: 0x000A5A76 File Offset: 0x000A3C76
	private static void LastErrorCallStack(string parameters)
	{
		SmartConsole.DumpCallStack(SmartConsole.s_lastErrorCallStack);
	}

	// Token: 0x06001A90 RID: 6800 RVA: 0x000A5A82 File Offset: 0x000A3C82
	private static void LastWarningCallStack(string parameters)
	{
		SmartConsole.DumpCallStack(SmartConsole.s_lastWarningCallStack);
	}

	// Token: 0x06001A91 RID: 6801 RVA: 0x000965EF File Offset: 0x000947EF
	private static void Quit(string parameters)
	{
		Application.Quit();
	}

	// Token: 0x06001A92 RID: 6802 RVA: 0x000A5A90 File Offset: 0x000A3C90
	private static void ListCvars(string parameters)
	{
		foreach (SmartConsole.Command command in SmartConsole.s_variableDictionary.Values)
		{
			string str = command.m_name;
			for (int i = command.m_name.Length; i < 50; i++)
			{
				str += " ";
			}
			SmartConsole.WriteLine(str + command.m_help);
		}
	}

	// Token: 0x06001A93 RID: 6803 RVA: 0x000A5B2C File Offset: 0x000A3D2C
	private static void Initialise(SmartConsole instance)
	{
		if (SmartConsole.s_textInput != null)
		{
			return;
		}
		UnityEngine.Object.DontDestroyOnLoad(instance);
		if (SmartConsole.<>f__mg$cache0 == null)
		{
			SmartConsole.<>f__mg$cache0 = new Application.LogCallback(SmartConsole.LogHandler);
		}
		Application.logMessageReceived += SmartConsole.<>f__mg$cache0;
		SmartConsole.InitialiseCommands();
		SmartConsole.InitialiseVariables();
		SmartConsole.InitialiseUI(instance);
	}

	// Token: 0x06001A94 RID: 6804 RVA: 0x000A5B84 File Offset: 0x000A3D84
	private static void HandleInput()
	{
		SmartConsole.s_toggleCooldown += ((Time.deltaTime >= 0.0166f) ? Time.deltaTime : 0.0166f);
		if (SmartConsole.s_toggleCooldown < 0.35f)
		{
			return;
		}
		if (Input.GetButtonUp(ButtonInput.OpenConsole))
		{
			if (!SmartConsole.s_consoleLock)
			{
				SmartConsole.s_showConsole = !SmartConsole.s_showConsole;
				if (SmartConsole.s_showConsole)
				{
					SmartConsole.s_currentInputLine = string.Empty;
				}
			}
			SmartConsole.s_toggleCooldown = 0f;
		}
		if (SmartConsole.s_commandHistory.Count > 0)
		{
			bool flag = false;
			if (Input.GetKeyDown(KeyCode.UpArrow))
			{
				flag = true;
				SmartConsole.s_currentCommandHistoryIndex--;
			}
			else if (Input.GetKeyDown(KeyCode.DownArrow))
			{
				flag = true;
				SmartConsole.s_currentCommandHistoryIndex++;
			}
			if (flag)
			{
				SmartConsole.s_currentCommandHistoryIndex = Mathf.Clamp(SmartConsole.s_currentCommandHistoryIndex, 0, SmartConsole.s_commandHistory.Count - 1);
				SmartConsole.s_currentInputLine = SmartConsole.s_commandHistory[SmartConsole.s_currentCommandHistoryIndex];
			}
		}
		SmartConsole.HandleTextInput();
	}

	// Token: 0x06001A95 RID: 6805 RVA: 0x000A5CA0 File Offset: 0x000A3EA0
	private static void InitialiseCommands()
	{
		string name = "clear";
		string helpDescription = "clear the console log";
		if (SmartConsole.<>f__mg$cache1 == null)
		{
			SmartConsole.<>f__mg$cache1 = new SmartConsole.ConsoleCommandFunction(SmartConsole.Clear);
		}
		SmartConsole.RegisterCommand(name, helpDescription, SmartConsole.<>f__mg$cache1);
		string name2 = "cls";
		string helpDescription2 = "clear the console log (alias for Clear)";
		if (SmartConsole.<>f__mg$cache2 == null)
		{
			SmartConsole.<>f__mg$cache2 = new SmartConsole.ConsoleCommandFunction(SmartConsole.Clear);
		}
		SmartConsole.RegisterCommand(name2, helpDescription2, SmartConsole.<>f__mg$cache2);
		string name3 = "echo";
		string exampleUsage = "echo <string>";
		string helpDescription3 = "writes <string> to the console log (alias for echo)";
		if (SmartConsole.<>f__mg$cache3 == null)
		{
			SmartConsole.<>f__mg$cache3 = new SmartConsole.ConsoleCommandFunction(SmartConsole.Echo);
		}
		SmartConsole.RegisterCommand(name3, exampleUsage, helpDescription3, SmartConsole.<>f__mg$cache3);
		string name4 = "help";
		string helpDescription4 = "displays help information for console command where available";
		if (SmartConsole.<>f__mg$cache4 == null)
		{
			SmartConsole.<>f__mg$cache4 = new SmartConsole.ConsoleCommandFunction(SmartConsole.Help);
		}
		SmartConsole.RegisterCommand(name4, helpDescription4, SmartConsole.<>f__mg$cache4);
		string name5 = "list";
		string helpDescription5 = "lists all currently registered console variables";
		if (SmartConsole.<>f__mg$cache5 == null)
		{
			SmartConsole.<>f__mg$cache5 = new SmartConsole.ConsoleCommandFunction(SmartConsole.ListCvars);
		}
		SmartConsole.RegisterCommand(name5, helpDescription5, SmartConsole.<>f__mg$cache5);
		string name6 = "print";
		string exampleUsage2 = "print <string>";
		string helpDescription6 = "writes <string> to the console log";
		if (SmartConsole.<>f__mg$cache6 == null)
		{
			SmartConsole.<>f__mg$cache6 = new SmartConsole.ConsoleCommandFunction(SmartConsole.Echo);
		}
		SmartConsole.RegisterCommand(name6, exampleUsage2, helpDescription6, SmartConsole.<>f__mg$cache6);
		string name7 = "quit";
		string helpDescription7 = "quit the game (not sure this works with iOS/Android)";
		if (SmartConsole.<>f__mg$cache7 == null)
		{
			SmartConsole.<>f__mg$cache7 = new SmartConsole.ConsoleCommandFunction(SmartConsole.Quit);
		}
		SmartConsole.RegisterCommand(name7, helpDescription7, SmartConsole.<>f__mg$cache7);
		string name8 = "callstack.warning";
		string helpDescription8 = "display the call stack for the last warning message";
		if (SmartConsole.<>f__mg$cache8 == null)
		{
			SmartConsole.<>f__mg$cache8 = new SmartConsole.ConsoleCommandFunction(SmartConsole.LastWarningCallStack);
		}
		SmartConsole.RegisterCommand(name8, helpDescription8, SmartConsole.<>f__mg$cache8);
		string name9 = "callstack.error";
		string helpDescription9 = "display the call stack for the last error message";
		if (SmartConsole.<>f__mg$cache9 == null)
		{
			SmartConsole.<>f__mg$cache9 = new SmartConsole.ConsoleCommandFunction(SmartConsole.LastErrorCallStack);
		}
		SmartConsole.RegisterCommand(name9, helpDescription9, SmartConsole.<>f__mg$cache9);
		string name10 = "callstack.exception";
		string helpDescription10 = "display the call stack for the last exception message";
		if (SmartConsole.<>f__mg$cacheA == null)
		{
			SmartConsole.<>f__mg$cacheA = new SmartConsole.ConsoleCommandFunction(SmartConsole.LastExceptionCallStack);
		}
		SmartConsole.RegisterCommand(name10, helpDescription10, SmartConsole.<>f__mg$cacheA);
	}

	// Token: 0x06001A96 RID: 6806 RVA: 0x000A5E70 File Offset: 0x000A4070
	private static void InitialiseVariables()
	{
		SmartConsole.s_drawFPS = SmartConsole.CreateVariable<bool>("show.fps", "whether to draw framerate counter or not", false);
		SmartConsole.s_drawFullConsole = SmartConsole.CreateVariable<bool>("console.fullscreen", "whether to draw the console over the whole screen or not", false);
		SmartConsole.s_consoleLock = SmartConsole.CreateVariable<bool>("console.lock", "whether to allow showing/hiding the console", false);
		SmartConsole.s_logging = SmartConsole.CreateVariable<bool>("console.log", "whether to redirect log to the console", true);
	}

	// Token: 0x06001A97 RID: 6807 RVA: 0x000A5ED4 File Offset: 0x000A40D4
	private static void InitialiseUI(SmartConsole instance)
	{
		SmartConsole.s_font = instance.m_font;
		if (SmartConsole.s_font == null)
		{
			Debug.LogError("SmartConsole needs to have a font set on an instance in the editor!");
			SmartConsole.s_font = new Font("Arial");
		}
		SmartConsole.s_fps = instance.AddChildWithGUIText("FPSCounter");
		SmartConsole.s_textInput = instance.AddChildWithGUIText("SmartConsoleInputField");
		SmartConsole.s_historyDisplay = new GameObject[120];
		for (int i = 0; i < 120; i++)
		{
			SmartConsole.s_historyDisplay[i] = instance.AddChildWithGUIText("SmartConsoleHistoryDisplay" + i);
		}
		instance.Layout();
	}

	// Token: 0x06001A98 RID: 6808 RVA: 0x000A5F77 File Offset: 0x000A4177
	private GameObject AddChildWithGUIText(string name)
	{
		return this.AddChildWithComponent<GUIText>(name);
	}

	// Token: 0x06001A99 RID: 6809 RVA: 0x000A5F80 File Offset: 0x000A4180
	private GameObject AddChildWithComponent<T>(string name) where T : Component
	{
		GameObject gameObject = new GameObject();
		gameObject.AddComponent<T>();
		gameObject.transform.parent = base.transform;
		gameObject.name = name;
		return gameObject;
	}

	// Token: 0x06001A9A RID: 6810 RVA: 0x000A5FB4 File Offset: 0x000A41B4
	private static void HandleTextInput()
	{
		if (!SmartConsole.inputEnabled)
		{
			return;
		}
		bool flag = false;
		string inputString = Input.inputString;
		int i = 0;
		while (i < inputString.Length)
		{
			char c = inputString[i];
			switch (c)
			{
			case '\b':
				SmartConsole.s_currentInputLine = ((SmartConsole.s_currentInputLine.Length <= 0) ? string.Empty : SmartConsole.s_currentInputLine.Substring(0, SmartConsole.s_currentInputLine.Length - 1));
				break;
			case '\t':
				SmartConsole.AutoComplete();
				flag = true;
				break;
			case '\n':
			case '\r':
				SmartConsole.ExecuteCurrentLine();
				SmartConsole.s_currentInputLine = string.Empty;
				break;
			case '\v':
			case '\f':
				goto IL_A2;
			default:
				goto IL_A2;
			}
			IL_BC:
			i++;
			continue;
			IL_A2:
			SmartConsole.s_currentInputLine += c;
			goto IL_BC;
		}
		if (!flag && Input.GetKeyDown(KeyCode.Tab))
		{
			SmartConsole.AutoComplete();
		}
	}

	// Token: 0x06001A9B RID: 6811 RVA: 0x000A60A4 File Offset: 0x000A42A4
	private static void ExecuteCurrentLine()
	{
		SmartConsole.ExecuteLine(SmartConsole.s_currentInputLine);
	}

	// Token: 0x06001A9C RID: 6812 RVA: 0x000A60B0 File Offset: 0x000A42B0
	private static void AutoComplete()
	{
		string[] array = SmartConsole.CComParameterSplit(SmartConsole.s_currentInputLine);
		if (array.Length == 0)
		{
			return;
		}
		SmartConsole.Command command = SmartConsole.s_masterDictionary.AutoCompleteLookup(array[0]);
		int num = 0;
		do
		{
			num = command.m_name.IndexOf(".", num + 1);
		}
		while (num > 0 && num < array[0].Length);
		string text = command.m_name;
		if (num >= 0)
		{
			text = command.m_name.Substring(0, num + 1);
		}
		if (text.Length < SmartConsole.s_currentInputLine.Length)
		{
			if (!SmartConsole.AutoCompleteTailString("true"))
			{
				if (!SmartConsole.AutoCompleteTailString("false"))
				{
					if (!SmartConsole.AutoCompleteTailString("True"))
					{
						if (!SmartConsole.AutoCompleteTailString("False"))
						{
							if (!SmartConsole.AutoCompleteTailString("TRUE"))
							{
								if (SmartConsole.AutoCompleteTailString("FALSE"))
								{
								}
							}
						}
					}
				}
			}
		}
		else if (text.Length >= SmartConsole.s_currentInputLine.Length)
		{
			SmartConsole.s_currentInputLine = text;
		}
	}

	// Token: 0x06001A9D RID: 6813 RVA: 0x000A61D8 File Offset: 0x000A43D8
	private static bool AutoCompleteTailString(string tailString)
	{
		for (int i = 1; i < tailString.Length; i++)
		{
			if (SmartConsole.s_currentInputLine.EndsWith(" " + tailString.Substring(0, i)))
			{
				SmartConsole.s_currentInputLine = SmartConsole.s_currentInputLine.Substring(0, SmartConsole.s_currentInputLine.Length - 1) + tailString.Substring(i - 1);
				return true;
			}
		}
		return false;
	}

	// Token: 0x06001A9E RID: 6814 RVA: 0x000A624C File Offset: 0x000A444C
	private void Layout()
	{
		float num = 0f;
		SmartConsole.LayoutTextAtY(SmartConsole.s_textInput, num);
		SmartConsole.LayoutTextAtY(SmartConsole.s_fps, num);
		num += 0.05f;
		for (int i = 0; i < 120; i++)
		{
			SmartConsole.LayoutTextAtY(SmartConsole.s_historyDisplay[i], num);
			num += 0.05f;
		}
	}

	// Token: 0x06001A9F RID: 6815 RVA: 0x000A62A5 File Offset: 0x000A44A5
	private static void LayoutTextAtY(GameObject o, float y)
	{
		o.transform.localPosition = new Vector3(0f, y, 0f);
		o.GetComponent<GUIText>().fontStyle = FontStyle.Normal;
		o.GetComponent<GUIText>().font = SmartConsole.s_font;
	}

	// Token: 0x06001AA0 RID: 6816 RVA: 0x000A62E0 File Offset: 0x000A44E0
	private static void SetStringsOnHistoryElements()
	{
		for (int i = 0; i < 120; i++)
		{
			int num = SmartConsole.s_outputHistory.Count - 1 - i;
			if (num >= 0)
			{
				SmartConsole.s_historyDisplay[i].GetComponent<GUIText>().text = SmartConsole.s_outputHistory[SmartConsole.s_outputHistory.Count - 1 - i];
			}
			else
			{
				SmartConsole.s_historyDisplay[i].GetComponent<GUIText>().text = string.Empty;
			}
		}
	}

	// Token: 0x06001AA1 RID: 6817 RVA: 0x000A635C File Offset: 0x000A455C
	private static void LogHandler(string message, string stack, LogType type)
	{
		if (!SmartConsole.s_logging)
		{
			return;
		}
		string text = "[Assert]:             ";
		string text2 = "[Debug.LogError]:     ";
		string text3 = "[Debug.LogException]: ";
		string text4 = "[Debug.LogWarning]:   ";
		string text5 = "[Debug.Log]:          ";
		if (message.StartsWith("Screen position out of view frustum"))
		{
			return;
		}
		string str = text5;
		switch (type)
		{
		case LogType.Error:
			str = text2;
			SmartConsole.s_lastErrorCallStack = stack;
			break;
		case LogType.Assert:
			str = text;
			break;
		case LogType.Warning:
			str = text4;
			SmartConsole.s_lastWarningCallStack = stack;
			break;
		case LogType.Exception:
			str = text3;
			SmartConsole.s_lastExceptionCallStack = stack;
			break;
		}
		SmartConsole.WriteLine(str + message);
		switch (type)
		{
		}
	}

	// Token: 0x06001AA2 RID: 6818 RVA: 0x000A6439 File Offset: 0x000A4639
	public static string[] CComParameterSplit(string parameters)
	{
		return parameters.Split(new char[]
		{
			' '
		}, StringSplitOptions.RemoveEmptyEntries);
	}

	// Token: 0x06001AA3 RID: 6819 RVA: 0x000A6450 File Offset: 0x000A4650
	public static string[] CComParameterSplit(string parameters, int requiredParameters)
	{
		string[] array = SmartConsole.CComParameterSplit(parameters);
		if (array.Length < requiredParameters + 1)
		{
			SmartConsole.WriteLine(string.Concat(new object[]
			{
				"Error: not enough parameters for command. Expected ",
				requiredParameters,
				" found ",
				array.Length - 1
			}));
		}
		if (array.Length > requiredParameters + 1)
		{
			int num = array.Length - 1 - requiredParameters;
			SmartConsole.WriteLine("Warning: " + num + "additional parameters will be dropped:");
			for (int i = array.Length - num; i < array.Length; i++)
			{
				SmartConsole.WriteLine("\"" + array[i] + "\"");
			}
		}
		return array;
	}

	// Token: 0x06001AA4 RID: 6820 RVA: 0x000A6504 File Offset: 0x000A4704
	private static string[] CVarParameterSplit(string parameters)
	{
		string[] array = SmartConsole.CComParameterSplit(parameters);
		if (array.Length == 0)
		{
			SmartConsole.WriteLine("Error: not enough parameters to set or display the value of a console variable.");
		}
		if (array.Length > 2)
		{
			int num = array.Length - 3;
			SmartConsole.WriteLine("Warning: " + num + "additional parameters will be dropped:");
			for (int i = array.Length - num; i < array.Length; i++)
			{
				SmartConsole.WriteLine("\"" + array[i] + "\"");
			}
		}
		return array;
	}

	// Token: 0x06001AA5 RID: 6821 RVA: 0x000A6583 File Offset: 0x000A4783
	private static string DeNewLine(string message)
	{
		return message.Replace("\n", " | ");
	}

	// Token: 0x06001AA6 RID: 6822 RVA: 0x000A6598 File Offset: 0x000A4798
	private static void DumpCallStack(string stackString)
	{
		string[] array = stackString.Split(new char[]
		{
			'\r',
			'\n'
		});
		if (array.Length == 0)
		{
			return;
		}
		int num = 0;
		while (array[array.Length - 1 - num].Length == 0 && num < array.Length)
		{
			num++;
		}
		int num2 = array.Length - num;
		for (int i = 0; i < num2; i++)
		{
			SmartConsole.WriteLine((i + 1).ToString() + ((i >= 9) ? " " : "  ") + array[i]);
		}
	}

	// Token: 0x06001AA7 RID: 6823 RVA: 0x000A663A File Offset: 0x000A483A
	private float SmootherStep(float t)
	{
		return ((6f * t - 15f) * t + 10f) * t * t * t;
	}

	// Token: 0x04001C44 RID: 7236
	public Font m_font;

	// Token: 0x04001C45 RID: 7237
	private const float k_animTime = 0.4f;

	// Token: 0x04001C46 RID: 7238
	private const float k_lineSpace = 0.05f;

	// Token: 0x04001C47 RID: 7239
	private const int k_historyLines = 120;

	// Token: 0x04001C48 RID: 7240
	private static Vector3 k_position = new Vector3(0.01f, 0.65f, 0f);

	// Token: 0x04001C49 RID: 7241
	private static Vector3 k_fullPosition = new Vector3(0.01f, 0.05f, 0f);

	// Token: 0x04001C4A RID: 7242
	private static Vector3 k_hidePosition = new Vector3(0.01f, 1.1f, 0f);

	// Token: 0x04001C4B RID: 7243
	private static Vector3 k_scale = new Vector3(0.5f, 0.5f, 1f);

	// Token: 0x04001C4C RID: 7244
	private static int s_flippy = 0;

	// Token: 0x04001C4D RID: 7245
	private static bool s_blink = false;

	// Token: 0x04001C4E RID: 7246
	private static bool s_first = true;

	// Token: 0x04001C4F RID: 7247
	private const float k_toogleCDTime = 0.35f;

	// Token: 0x04001C50 RID: 7248
	private static float s_toggleCooldown = 0f;

	// Token: 0x04001C51 RID: 7249
	private static int s_currentCommandHistoryIndex = 0;

	// Token: 0x04001C52 RID: 7250
	private static Font s_font = null;

	// Token: 0x04001C53 RID: 7251
	private static SmartConsole.Variable<bool> s_drawFPS = null;

	// Token: 0x04001C54 RID: 7252
	private static SmartConsole.Variable<bool> s_drawFullConsole = null;

	// Token: 0x04001C55 RID: 7253
	private static SmartConsole.Variable<bool> s_consoleLock = null;

	// Token: 0x04001C56 RID: 7254
	private static SmartConsole.Variable<bool> s_logging = null;

	// Token: 0x04001C57 RID: 7255
	private static GameObject s_fps = null;

	// Token: 0x04001C58 RID: 7256
	private static GameObject s_textInput = null;

	// Token: 0x04001C59 RID: 7257
	private static GameObject[] s_historyDisplay = null;

	// Token: 0x04001C5A RID: 7258
	private static SmartConsole.AutoCompleteDictionary<SmartConsole.Command> s_commandDictionary = new SmartConsole.AutoCompleteDictionary<SmartConsole.Command>();

	// Token: 0x04001C5B RID: 7259
	private static SmartConsole.AutoCompleteDictionary<SmartConsole.Command> s_variableDictionary = new SmartConsole.AutoCompleteDictionary<SmartConsole.Command>();

	// Token: 0x04001C5C RID: 7260
	private static SmartConsole.AutoCompleteDictionary<SmartConsole.Command> s_masterDictionary = new SmartConsole.AutoCompleteDictionary<SmartConsole.Command>();

	// Token: 0x04001C5D RID: 7261
	private static List<string> s_commandHistory = new List<string>();

	// Token: 0x04001C5E RID: 7262
	private static List<string> s_outputHistory = new List<string>();

	// Token: 0x04001C5F RID: 7263
	private static string s_lastExceptionCallStack = "(none yet)";

	// Token: 0x04001C60 RID: 7264
	private static string s_lastErrorCallStack = "(none yet)";

	// Token: 0x04001C61 RID: 7265
	private static string s_lastWarningCallStack = "(none yet)";

	// Token: 0x04001C62 RID: 7266
	private static string s_currentInputLine = string.Empty;

	// Token: 0x04001C63 RID: 7267
	private static float s_visiblityLerp = 0f;

	// Token: 0x04001C64 RID: 7268
	private static bool s_showConsole = false;

	// Token: 0x04001C65 RID: 7269
	public static bool inputEnabled = false;

	// Token: 0x04001C66 RID: 7270
	[CompilerGenerated]
	private static Application.LogCallback <>f__mg$cache0;

	// Token: 0x04001C67 RID: 7271
	[CompilerGenerated]
	private static SmartConsole.ConsoleCommandFunction <>f__mg$cache1;

	// Token: 0x04001C68 RID: 7272
	[CompilerGenerated]
	private static SmartConsole.ConsoleCommandFunction <>f__mg$cache2;

	// Token: 0x04001C69 RID: 7273
	[CompilerGenerated]
	private static SmartConsole.ConsoleCommandFunction <>f__mg$cache3;

	// Token: 0x04001C6A RID: 7274
	[CompilerGenerated]
	private static SmartConsole.ConsoleCommandFunction <>f__mg$cache4;

	// Token: 0x04001C6B RID: 7275
	[CompilerGenerated]
	private static SmartConsole.ConsoleCommandFunction <>f__mg$cache5;

	// Token: 0x04001C6C RID: 7276
	[CompilerGenerated]
	private static SmartConsole.ConsoleCommandFunction <>f__mg$cache6;

	// Token: 0x04001C6D RID: 7277
	[CompilerGenerated]
	private static SmartConsole.ConsoleCommandFunction <>f__mg$cache7;

	// Token: 0x04001C6E RID: 7278
	[CompilerGenerated]
	private static SmartConsole.ConsoleCommandFunction <>f__mg$cache8;

	// Token: 0x04001C6F RID: 7279
	[CompilerGenerated]
	private static SmartConsole.ConsoleCommandFunction <>f__mg$cache9;

	// Token: 0x04001C70 RID: 7280
	[CompilerGenerated]
	private static SmartConsole.ConsoleCommandFunction <>f__mg$cacheA;

	// Token: 0x020003C9 RID: 969
	// (Invoke) Token: 0x06001AAA RID: 6826
	public delegate void ConsoleCommandFunction(string parameters);

	// Token: 0x020003CA RID: 970
	public class Command
	{
		// Token: 0x04001C71 RID: 7281
		public SmartConsole.ConsoleCommandFunction m_callback;

		// Token: 0x04001C72 RID: 7282
		public string m_name;

		// Token: 0x04001C73 RID: 7283
		public string m_paramsExample = string.Empty;

		// Token: 0x04001C74 RID: 7284
		public string m_help = "(no description)";
	}

	// Token: 0x020003CB RID: 971
	public class Variable<T> : SmartConsole.Command where T : new()
	{
		// Token: 0x06001AAE RID: 6830 RVA: 0x000A67A9 File Offset: 0x000A49A9
		public Variable(string name)
		{
			this.Initialise(name, string.Empty, Activator.CreateInstance<T>());
		}

		// Token: 0x06001AAF RID: 6831 RVA: 0x000A67C2 File Offset: 0x000A49C2
		public Variable(string name, string description)
		{
			this.Initialise(name, description, Activator.CreateInstance<T>());
		}

		// Token: 0x06001AB0 RID: 6832 RVA: 0x000A67D7 File Offset: 0x000A49D7
		public Variable(string name, T initialValue)
		{
			this.Initialise(name, string.Empty, initialValue);
		}

		// Token: 0x06001AB1 RID: 6833 RVA: 0x000A67EC File Offset: 0x000A49EC
		public Variable(string name, string description, T initalValue)
		{
			this.Initialise(name, description, initalValue);
		}

		// Token: 0x06001AB2 RID: 6834 RVA: 0x000A67FD File Offset: 0x000A49FD
		public void Set(T val)
		{
			this.m_value = val;
		}

		// Token: 0x06001AB3 RID: 6835 RVA: 0x000A6806 File Offset: 0x000A4A06
		public static implicit operator T(SmartConsole.Variable<T> var)
		{
			return var.m_value;
		}

		// Token: 0x06001AB4 RID: 6836 RVA: 0x000A6810 File Offset: 0x000A4A10
		private void Initialise(string name, string description, T initalValue)
		{
			this.m_name = name;
			this.m_help = description;
			this.m_paramsExample = string.Empty;
			this.m_value = initalValue;
			if (SmartConsole.Variable<T>.<>f__mg$cache0 == null)
			{
				SmartConsole.Variable<T>.<>f__mg$cache0 = new SmartConsole.ConsoleCommandFunction(SmartConsole.Variable<T>.CommandFunction);
			}
			this.m_callback = SmartConsole.Variable<T>.<>f__mg$cache0;
		}

		// Token: 0x06001AB5 RID: 6837 RVA: 0x000A6860 File Offset: 0x000A4A60
		private static void CommandFunction(string parameters)
		{
			string[] array = SmartConsole.CVarParameterSplit(parameters);
			if (array.Length != 0 && SmartConsole.s_variableDictionary.ContainsKey(array[0]))
			{
				SmartConsole.Variable<T> variable = SmartConsole.s_variableDictionary[array[0]] as SmartConsole.Variable<T>;
				string arg = " is set to ";
				if (array.Length == 2)
				{
					variable.SetFromString(array[1]);
					arg = " has been set to ";
				}
				SmartConsole.WriteLine(variable.m_name + arg + variable.m_value);
			}
		}

		// Token: 0x06001AB6 RID: 6838 RVA: 0x000A68DB File Offset: 0x000A4ADB
		private void SetFromString(string value)
		{
			this.m_value = (T)((object)Convert.ChangeType(value, typeof(T)));
		}

		// Token: 0x04001C75 RID: 7285
		private T m_value;

		// Token: 0x04001C76 RID: 7286
		[CompilerGenerated]
		private static SmartConsole.ConsoleCommandFunction <>f__mg$cache0;
	}

	// Token: 0x020003CC RID: 972
	private class AutoCompleteDictionary<T> : SortedDictionary<string, T>
	{
		// Token: 0x06001AB7 RID: 6839 RVA: 0x000A68F8 File Offset: 0x000A4AF8
		public AutoCompleteDictionary() : base(new SmartConsole.AutoCompleteDictionary<T>.AutoCompleteComparer())
		{
			this.m_comparer = (base.Comparer as SmartConsole.AutoCompleteDictionary<T>.AutoCompleteComparer);
		}

		// Token: 0x06001AB8 RID: 6840 RVA: 0x000A6916 File Offset: 0x000A4B16
		public T LowerBound(string lookupString)
		{
			this.m_comparer.Reset();
			base.ContainsKey(lookupString);
			return base[this.m_comparer.LowerBound];
		}

		// Token: 0x06001AB9 RID: 6841 RVA: 0x000A693C File Offset: 0x000A4B3C
		public T UpperBound(string lookupString)
		{
			this.m_comparer.Reset();
			base.ContainsKey(lookupString);
			return base[this.m_comparer.UpperBound];
		}

		// Token: 0x06001ABA RID: 6842 RVA: 0x000A6964 File Offset: 0x000A4B64
		public T AutoCompleteLookup(string lookupString)
		{
			this.m_comparer.Reset();
			base.ContainsKey(lookupString);
			string key = (this.m_comparer.UpperBound != null) ? this.m_comparer.UpperBound : this.m_comparer.LowerBound;
			return base[key];
		}

		// Token: 0x04001C77 RID: 7287
		private SmartConsole.AutoCompleteDictionary<T>.AutoCompleteComparer m_comparer;

		// Token: 0x020003CD RID: 973
		private class AutoCompleteComparer : IComparer<string>
		{
			// Token: 0x170003BC RID: 956
			// (get) Token: 0x06001ABC RID: 6844 RVA: 0x000A69B7 File Offset: 0x000A4BB7
			public string LowerBound
			{
				get
				{
					return this.m_lowerBound;
				}
			}

			// Token: 0x170003BD RID: 957
			// (get) Token: 0x06001ABD RID: 6845 RVA: 0x000A69BF File Offset: 0x000A4BBF
			public string UpperBound
			{
				get
				{
					return this.m_upperBound;
				}
			}

			// Token: 0x06001ABE RID: 6846 RVA: 0x000A69C8 File Offset: 0x000A4BC8
			public int Compare(string x, string y)
			{
				int num = Comparer<string>.Default.Compare(x, y);
				if (num >= 0)
				{
					this.m_lowerBound = y;
				}
				if (num <= 0)
				{
					this.m_upperBound = y;
				}
				return num;
			}

			// Token: 0x06001ABF RID: 6847 RVA: 0x000A69FF File Offset: 0x000A4BFF
			public void Reset()
			{
				this.m_lowerBound = null;
				this.m_upperBound = null;
			}

			// Token: 0x04001C78 RID: 7288
			private string m_lowerBound;

			// Token: 0x04001C79 RID: 7289
			private string m_upperBound;
		}
	}
}
